package qos.estimator.fuzzy;


public class LabGCCBD3FuzzyRegionsSystemCommand implements ConfigureSystemCommand {

	private FuzzyEstimator fuzzyEstimator;

	
	@Override
	public void configureSystem(FuzzyEstimator fuzzyEstimator) {
		this.fuzzyEstimator = fuzzyEstimator;
		configureBuffers();
		configureMemoryPercentual();
		configureCpuIOWaitPercentual();
		configureCpuSoftPercentual();
		configureCpuSysPercentual();
		configureCpuUsrPercentual();
		configureResidentSetSize();
		configureVirtualSize();
		configureMinorFaultsPerSecond();
		configureMajorFaultsPerSecond();
		configureInterruptionsPerSecond();
		configureDiskUsage();
		configureConcSessions();
		configureLocks();
		configureElapsedTime();
	}
	


	private void configureBuffers( ) {
		//Original values - first value is set to 0.
		//fuzzyEstimator.buffers.add("low", 678342, 2179132.75, 3679923.5);
		fuzzyEstimator.buffers.add("low", 0, 2179132.75, 3679923.5);
		fuzzyEstimator.buffers.add("middle", 2179132.75, 3679923.5, 5180714.25);
		fuzzyEstimator.buffers.add("high", 3679923.5, 5180714.25, 66815050);
		//Original values - last number is times 10.
		//fuzzyEstimator.buffers.add("high", 3679923.5, 5180714.25, 6681505);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.buffers);		
		
	}

	private void configureLocks() {
		//fuzzyEstimator.locks.add("low", 6, 37, 68);
		fuzzyEstimator.locks.add("low", 0, 37, 68);
		fuzzyEstimator.locks.add("middle", 37, 68, 99);
		fuzzyEstimator.locks.add("high", 68, 99, 1300);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.locks);		
		
	}

	private void configureConcSessions() {
		//fuzzyEstimator.concSessions.add("low", 2, 5.5, 9);
		fuzzyEstimator.concSessions.add("low", 0, 5.5, 9);
		fuzzyEstimator.concSessions.add("middle", 5.5, 9, 12.5);
		fuzzyEstimator.concSessions.add("high", 9, 12.5, 160);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.concSessions);		
	}
	
	private void configureElapsedTime() {
		//fuzzyEstimator.elapsedTime.add("low", 33514, 164492, 295470);
		fuzzyEstimator.elapsedTime.add("low", 0, 164492, 295470);
		fuzzyEstimator.elapsedTime.add("middle", 164492, 295470, 426448);
		fuzzyEstimator.elapsedTime.add("high", 295470, 426448, 5574260);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.elapsedTime);//Alterado
	}

	private void configureMemoryPercentual() {
		//fuzzyEstimator.memoryPercentual.add("low", 44.24, 51.4325, 58.625);
		fuzzyEstimator.memoryPercentual.add("low", 0, 51.4325, 58.625);
		fuzzyEstimator.memoryPercentual.add("middle", 51.4325, 58.625, 65.8175);
		//fuzzyEstimator.memoryPercentual.add("high", 58.625, 65.8175, 73.01);
		fuzzyEstimator.memoryPercentual.add("high", 58.625, 65.8175, 100);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.memoryPercentual);//Alterado
	}

	private void configureCpuIOWaitPercentual() {
		//fuzzyEstimator.cpuIOWaitPercentual.add("low", 26.12, 43.725, 61.33);
		fuzzyEstimator.cpuIOWaitPercentual.add("low", 0, 43.725, 61.33);
		fuzzyEstimator.cpuIOWaitPercentual.add("middle", 43.725, 61.33, 78.935);
		//fuzzyEstimator.cpuIOWaitPercentual.add("high", 61.33, 78.935, 96.54);
		fuzzyEstimator.cpuIOWaitPercentual.add("high", 61.33, 78.935, 100);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.cpuIOWaitPercentual);
	}

	private void configureCpuSoftPercentual() {
		fuzzyEstimator.cpuSoftPercentual.add("low", -0.1, 0.165, 0.33);
		fuzzyEstimator.cpuSoftPercentual.add("middle", 0.165, 0.33, 0.495);
		//fuzzyEstimator.cpuSoftPercentual.add("high", 0.33, 0.495, 0.66);
		fuzzyEstimator.cpuSoftPercentual.add("high", 0.33, 0.495, 100);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.cpuSoftPercentual);
	}

	private void configureCpuSysPercentual() {
		//fuzzyEstimator.cpuSysPercentual.add("low", 0.89, 3.41, 5.93);
		fuzzyEstimator.cpuSysPercentual.add("low", 0, 3.41, 5.93);
		fuzzyEstimator.cpuSysPercentual.add("middle", 3.41, 5.93, 8.45);
		//fuzzyEstimator.cpuSysPercentual.add("high", 5.93, 8.45, 10.97);
		fuzzyEstimator.cpuSysPercentual.add("high", 5.93, 8.45, 100);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.cpuSysPercentual);//Alterado
	}

	private void configureCpuUsrPercentual() {
		//fuzzyEstimator.cpuUsrPercentual.add("low", 1.68, 15.4325, 29.185);
		fuzzyEstimator.cpuUsrPercentual.add("low", 0, 15.4325, 29.185);
		fuzzyEstimator.cpuUsrPercentual.add("middle", 15.4325, 29.185, 42.9375);
		//fuzzyEstimator.cpuUsrPercentual.add("high", 29.185, 42.9375, 56.69);
		fuzzyEstimator.cpuUsrPercentual.add("high", 29.185, 42.9375, 100);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.cpuUsrPercentual);//Alterado
	}

	private void configureResidentSetSize() {
		//fuzzyEstimator.residentSetSize.add("low", 910032, 1058803, 1207574);
		fuzzyEstimator.residentSetSize.add("low", 0, 1058803, 1207574);
		fuzzyEstimator.residentSetSize.add("middle", 1058803, 1207574, 1356345);
		//fuzzyEstimator.residentSetSize.add("high", 1207574, 1356345, 1505116);
		fuzzyEstimator.residentSetSize.add("high", 1207574, 1356345, 15051160);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.residentSetSize); //Alterado
	}

	private void configureVirtualSize() {
		//fuzzyEstimator.virtualSize.add("low", 6113136, 6604519, 7095902);
		fuzzyEstimator.virtualSize.add("low", 0, 6604519, 7095902);
		fuzzyEstimator.virtualSize.add("middle", 6604519, 7095902, 7587285);
		//fuzzyEstimator.virtualSize.add("high", 7095902, 7587285, 8078668);
		fuzzyEstimator.virtualSize.add("high", 7095902, 7587285, 80786680);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.virtualSize);//Alterado
	}

	private void configureMinorFaultsPerSecond() {
		//fuzzyEstimator.minorFaultsPerSecond.add("low", 90.6, 101149.8875, 202209.175);
		fuzzyEstimator.minorFaultsPerSecond.add("low", 0, 101149.8875, 202209.175);
		fuzzyEstimator.minorFaultsPerSecond.add("middle", 101149.8875, 202209.175, 303268.4625);
		//fuzzyEstimator.minorFaultsPerSecond.add("high", 202209.175, 303268.4625, 404327.75);
		fuzzyEstimator.minorFaultsPerSecond.add("high", 202209.175, 303268.4625, 4043270.75);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.minorFaultsPerSecond);//Alterado
	}

	private void configureMajorFaultsPerSecond() {
		fuzzyEstimator.majorFaultsPerSecond.add("low", 0, 571.605, 1143.21);
		fuzzyEstimator.majorFaultsPerSecond.add("middle", 571.605, 1143.21, 1714.815);
		//fuzzyEstimator.majorFaultsPerSecond.add("high", 1143.21, 1714.815, 2286.42);
		fuzzyEstimator.majorFaultsPerSecond.add("high", 1143.21, 1714.815, 22860.42);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.majorFaultsPerSecond);//Alterado
	}

	private void configureInterruptionsPerSecond() {
		//fuzzyEstimator.interruptionsPerSecond.add("low", 643.4, 955.35, 1267.3);
		fuzzyEstimator.interruptionsPerSecond.add("low", 0, 955.35, 1267.3);
		fuzzyEstimator.interruptionsPerSecond.add("middle", 955.35, 1267.3, 1579.25);
		//fuzzyEstimator.interruptionsPerSecond.add("high", 1267.3, 1579.25, 1891.2);
		fuzzyEstimator.interruptionsPerSecond.add("high", 1267.3, 1579.25, 18910.2);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.interruptionsPerSecond);//Alterado
	}

	private void configureDiskUsage() {
		//fuzzyEstimator.diskUsage.add("low", 11126.4, 107353.2, 203580);
		fuzzyEstimator.diskUsage.add("low", 0, 107353.2, 203580);
		fuzzyEstimator.diskUsage.add("middle", 107353.2, 203580, 299806.8);
		//fuzzyEstimator.diskUsage.add("high", 203580, 299806.8, 396033.6);
		fuzzyEstimator.diskUsage.add("high", 203580, 299806.8, 3960330.6);
		fuzzyEstimator.getFuzzyEngine().register(fuzzyEstimator.diskUsage);
	}


}
